/*
 * COPYRIGHT Avetti.com Corporation 1998-2012.  All Rights Reserved
 */
package com.avetti.commerce.webservices;

import java.util.List;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.fault.XFireFault;

import com.avetti.commerce.domainmodel.Itemattrib;

/**
 * Inteface to call Avetti Commerce item service
 * @author AlekseyM
 */
public interface ItemService {
    public void delete(Items item);
    public void update(Items item);
    public Items create(Items item);
    public Items find1(String itemCode);
    public List<Items> findItemsAfterCurrentId(int startItemId, int fetchSize);
    public List<Itemattrib> findItemAttributeLinkInfo(Items item);
    public void attach1(Items item, Attributes attribute, int position);
    public void detach(Items item, Attributes attribute);
    
    public Items find(Long itemId);

    public Items find(String itemCode);


    public List<Items> find(List<Long> itemsIdList);


    public void delete(List<Long> itemIds);

    /**
     * Find a info about link between item and attribute, which attached to it.
     * 
     * @param item
     *            item.
     * @param attribute
     *            attribute.
     * @throws XFireFault
     *             is case of item update errors: items with the same name
     * @return itemattrib domain model, which contains a info about link between
     *         item and attached attribute.
     */
    public Itemattrib findItemAttributeLinkInfo(Items item,
            Attributes attribute, MessageContext context);


    /**
     * Find items that has related items
     * 
     * @param vendorId
     *            vendor identifier
     * @return list of items
     */
    public List<Items> findItemsWithRelations(MessageContext context);

    /**
     * Find related items
     * 
     * @param item
     *            instance
     * @return list of items
     */
    public List<Items> findRelatedItems(Items item, MessageContext context);


    /**
     * Create an item. sets 1 image for large, item and thumbnail using the
     * itemcode as the image name.
     * 
     * @param itemcode
     *            item code
     * @param title
     *            item title
     * @param description
     *            item description
     * @param description2
     *            second item description
     * @param listPrice
     *            item list price
     * @param priceParam
     *            item price
     * @param context
     *            SOAP message context
     * @return
     * @throws XFireFault
     *             is case of item update errors: items with the same name
     *             exists or no vendor id specified
     */
    public Items createProduct(String itemcode, String title,
            String description, String description2, double listPrice,
            double priceParam, MessageContext context) throws XFireFault;

    /**
     * Attach item to category by item code and category name.
     * 
     * @param categoryname
     *            category name
     * @param itemcode
     *            item code
     * @param updatebreadcrumb
     *            if updatebreadcrumb is true then sets the breadcrumb category
     *            in the item record to this category
     * @param context
     *            SOAP message context
     * @throws XFireFault
     */
    public Items attachProduct(String itemcode, String categoryname,
            boolean updatebreadcrumb, MessageContext context) throws XFireFault;

    /**
     * Update an item
     * 
     * @param item item to update
     * @param context SOAP message context
     * @throws XFireFault
     */
    public void updateItem(Items item, MessageContext context) throws XFireFault;
    
    /**
     * Get the customization item code for the given item Id.
     * @param itemId
     * @param context SOAP message context
     * @return
     */
    public String getCustomizationItemCode(long itemId, MessageContext context);
    
    /**
     * Attach the customization item to the given item Id. if customizationItemCode is empty, 
     * customization item existing will be detached. 
     * @param itemId
     * @param context SOAP message context
     * @param customizationItemCode
     */
    public void setCustomizationCode(long itemId, String customizationItemCode, MessageContext context);
    
    /**
     * Get the customization item Id for the given item Id.
     * @param itemId
     * @param context SOAP message context
     * @return the customization item id for the given item id. null if the corresponding customization
     * item id does not exist. 
     */
    public Long getCustomizationItemId(long itemId, MessageContext context);
    

    /**
     * Set the customization item for the given item id. If customziationItemId is null, existing customization 
     * item will be detached
     * @param itemId
     * @param customziationItemId
     * @param context SOAP message context
     */
    public void setCustomizationItem(long itemId, Long customziationItemId, MessageContext context);
    
}